package com.tucc.hello.leetcode.no1_400.no1_200.no81_100.no91;

/**
 * @author tucc
 * @description todo
 * @package com.tucc.hello.leetcode
 * @date 2021/5/20
 **/
public class Solution2 {

    public static void main(String[] args) {
        Solution2 solution = new Solution2();
        System.out.println(solution.numDecodings("111111111111111111111111111111111111111111111"));
    }

    private int count = 0;

    public int numDecodings(String s) {
        count = 0;
        numDecodings(s, 0);
        return count;
    }

    public void numDecodings(String s, int curIndex) {
        if (curIndex == s.length()) {
            count++;
        } else {
            char ch = s.charAt(curIndex);
            if (ch != '0') {
                if (ch <= '2') {
                    if (curIndex + 1 < s.length()) {
                        if (ch == '1' || s.charAt(curIndex + 1) <= '6') {
                            numDecodings(s, curIndex + 2);
                        }
                    }
                }
                numDecodings(s, curIndex + 1);
            }
        }
    }
}
